﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using RealState.BLL;
using RealState.BusinessObjects;
using System.Collections.Generic;
using log4net;

namespace RealState.W
{
    public partial class Default : System.Web.UI.Page
    {
        private Images imageBO;
        private ImagesBLL imageBLL;
        private CategoriesBLL categoriesBLL;
        private List<Images> listImage;
        private static List<Categories> listCategories;
        protected ILog log = LogManager.GetLogger("Default");
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                LoadImages();
                LoadCategories();
            }
        }
        public void LoadImages()
        {
            imageBO = new Images();
            imageBLL = new ImagesBLL();
            try
            {
                listImage = imageBLL.GetPartners();

                RepeaterPartners.DataSource = listImage;
                RepeaterPartners.DataBind();
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
            }
        }
        public void LoadCategories()
        {
            categoriesBLL = new CategoriesBLL();
            try
            {
                listCategories = categoriesBLL.GetCategoriess();
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
            }
            finally
            {
                categoriesBLL = null;
            }
            Repeater1.DataSource = listCategories.Where(c => c.ParentId == 1);
            Repeater1.DataBind();
            Repeater2.DataSource = listCategories.Where(c => c.ParentId == 5);
            Repeater2.DataBind();
            Repeater3.DataSource = listCategories.Where(c => c.ParentId == 8);
            Repeater3.DataBind();
            Repeater4.DataSource = listCategories.Where(c => c.ParentId == 13);
            Repeater4.DataBind();
        }
    }
}
